package httpHandle

import (
	"github.com/gin-gonic/gin"
	hyperNexusCommon "github.com/wzh200x/hyperNexus/hyperNexusCommon"
	"github.com/wzh200x/webServer/httpHandle/service"
	"github.com/wzh200x/webServer/middleware/response"
)

// 使用service包中定义的请求和响应结构
type ServerResponse service.ServerResponse
type ServerInfo service.ServerInfo

// HandleQueryServer 处理查询服务器信息请求
func HandleQueryServer(c *gin.Context) {
	success, err := response.GetResponseFuncs(c)

	// 调用service层获取服务器信息
	servers, errCode, errMsg := service.GetServers()
	if errCode > 0 {
		err(errCode, errMsg)
		return
	}

	// 返回服务器信息
	success(servers)
}

// 获取服务器时间
func HandleQueryTime(c *gin.Context) {
	success, _ := response.GetResponseFuncs(c)

	// 调用service层获取服务器时间
	now := hyperNexusCommon.GetCurrentTimeMilliseconds()

	// 返回服务器时间
	success(now)
}
